import request from '@/utils/request'

// 获取SPU接口，/admin/product/{page}/{limit}， get
export const reqgetSpuInfo = (page, limit, category3Id) => request({
    url: `/admin/product/${page}/${limit}?category3Id=${category3Id}`,
    method: 'get',
    // params: {category3Id}    // 注意参数category3Id
})

// 获取SpuForm表单数据，表单信息；/admin/product/getSpuById/{spuId}， get
export const reqgetSpuById = (getSpuById) => request({
    url: `/admin/product/getSpuById/${getSpuById}`,
    method: 'get',
})

//获取SpuForm表单数据，品牌信息 ，GET /admin/product/baseTrademark/getTrademarkList
export const reqgetTrademarkList = () => request({
    url: '/admin/product/baseTrademark/getTrademarkList',
    method: 'get',
})

//获取SpuForm表单数据，Spu图片 /admin/product/spuImageList/{spuId}， get
export const reqspuImageList = (spuId) => request({
    url: `/admin/product/spuImageList/${spuId}`,
    method: 'get',
})

//获取SpuForm表单数据，平台销售属性， /admin/product/baseSaleAttrList， get
export const reqbaseSaleAttrList = () => request({
    url: '/admin/product/baseSaleAttrList',
    method: 'get',
})

// SpuForm表单数据的保存，添加||修改，
// 添加：POST /admin/product/saveSpuInfo
// 修改：POST /admin/product/updateSpuInfo
export const reqSaveOrUpdateSpuInfo = (data) =>{
    if(data.id){
        return request({
            url: '/admin/product/updateSpuInfo',
            method: 'post',
            data,
        })
    }else{
        return request({
            url: '/admin/product/saveSpuInfo',
            method: 'post',
            data,
        })
    }
}

// 删除SPU, DELETE /admin/product/deleteSpu/{spuId}
export const reqDeleteSpu = (spuId) => request({
    url: `/admin/product/deleteSpu/${spuId}`,
    method: 'delete',
})

//获取SpuForm表单数据，平台销售属性， GET /admin/product/spuSaleAttrList/{spuId}
export const reqspuSaleAttrList = (spuId) => request({
    url: `/admin/product/spuSaleAttrList/${spuId}`,
    method: 'get',
})

// 获取品牌基础信息， /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}， get
export const reqgetCategoryInfoList = (category1Id, category2Id, category3Id) => request({
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method: 'get'
})

// 添加Sku，保存    POST /admin/product/saveSkuInfo
export const reqsaveSkuInfo = (data) => request({
    url: '/admin/product/saveSkuInfo',
    method: 'post',
    data
})

// 查看sku列表，GET /admin/product/findBySpuId/{spuId}
export const reqfindBySpuId = (spuId) => request({
    url: `/admin/product/findBySpuId/${spuId}`,
    method: 'get',
})
